#include "proxydialog.h"
#include "ui_proxydialog.h"
#include "singletondownloader.h"
ProxyDialog::ProxyDialog(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::ProxyDialog)
{
    ui->setupUi(this);

}

ProxyDialog::~ProxyDialog()
{
    delete ui;
}

void ProxyDialog::closeEvent(QCloseEvent*e){
    this->QDialog::closeEvent(e);
    delete this;
}

void ProxyDialog::on_removeBox_clicked(){
    if(ui->removeBox->isChecked()){
        ui->host->setDisabled(true);
        ui->label->setDisabled(true);
        ui->port->setDisabled(true);
        ui->label_2->setDisabled(true);
    }else{
        ui->host->setDisabled(false);
        ui->label->setDisabled(false);
        ui->port->setDisabled(false);
        ui->label_2->setDisabled(false);
    }
}

void ProxyDialog::on_setButton_clicked(){
    SingletonDownloader * downloader = SingletonDownloader::getInstance();
    if(ui->removeBox->isChecked()) downloader->proxyRemove();
    else downloader->proxySet(ui->host->text(),ui->port->text().toUInt());
    this->close();
}
